package optimizers.ganeat.sin;

import java.util.HashMap;
import java.util.Map;

import javax.swing.JPanel;

import common.RunStatus;

import model.OligoSystemGeneral;

import fitness.Fitness;
import fitness.SineFitness;

import optimizers.commons.RunConfig;
import optimizers.ganeat.Connection;
import optimizers.ganeat.Constants;
import optimizers.ganeat.GA;
import optimizers.ganeat.Individual;
import optimizers.ganeat.Node;
import optimizers.ganeat.Species;
import optimizers.ganeat.bistableswitch.IndividualBistableSwitch;
import optimizers.ganeat.triangleup.IndividualTriangleUp;
import runconfiguration.SinConfiguration;
import visualization.GraphDisplayer;

public class GASin extends GA {

	public GASin(RunConfig config, JPanel panelFitness, JPanel panelSpecies,
			JPanel panelIndiv, RunStatus runStatus) {
		super(config, panelFitness, panelSpecies, panelIndiv, runStatus);
		// TODO Auto-generated constructor stub
	}

	@Override
	public Individual getInitialIndividual() {
		IndividualSin indiv = new IndividualSin(innovations, nodeNames, -1, 0,
				config, "Node gens:\r\n" + " A 10 0\r\n" + " a 25 0\r\n"
						+ " b 25 50\r\n" + " c 25 10\r\n" + " Ca 25 0\r\n"
						+ " Cb 25 50\r\n" + " Cc 25 10\r\n"
						+ " g 10 0.0001\r\n" + " Ibb 0.25 0\r\n"
						+ " Igg 0.1 50\r\n" + " h 10 1\r\n"
						+ " IaCb 0.25 0\r\n" + " Ihh 0.1 100\r\n"
						+ "Connection gens:\r\n" + " 2 b->b true 3\r\n"
						+ " 3 a->Cb true 0.1\r\n" + " 4 a->Ibb true 0.01\r\n"
						+ " 5 g->g true 40\r\n" + " 6 g->Ibb true 15\r\n"
						+ " 7 b->Igg true 21\r\n" + " 8 h->h true 10\r\n"
						+ " 9 h->IaCb true 50\r\n" + " 10 b->Ihh true 50\r\n"
						+ "Exo: 0.68181\r\n" + "Pol: 26.25\r\n" + "Nick: 2.6");
		return indiv;
	}

	@Override
	public Individual getNewIndividual(Map<String, Integer> innovations2,
			Map<String, String> nodeNames2, int i, int j) {
		return new IndividualSin(innovations2, nodeNames2, i, j, config);
	}

	@Override
	public String getProblemName() {
		return "Sin";
	}

	public static void main(String[] args) {
		Individual indiv = new GASin(new SinConfiguration(), null, null, null,
				null).getInitialIndividual();
		GraphDisplayer displayer = new GraphDisplayer(1200, 700);
		double[][] timeSeries = indiv.getOligoModel()
				.getTimeSeriesComplexModel();
		OligoSystemGeneral oligo = indiv.getOligoModel();
		oligo.TimeSerie = timeSeries;
		oligo.indiv = indiv;
		displayer.addGraph(oligo.getVisualization(250, 250),
				indiv.displayTimeSereis(), indiv.printModelInTextArea());
		displayer.display();
	}
}
